package com.itfreer.gis.graphic;

import java.util.ArrayList;
import java.util.List;

/**
 * 多边形要素或者面要素
 * @author gj
 *
 */
public class GisPolyg extends GisGraphic{
	/**
	 * 解析坐标点位
	 */
	List<GisPoint> points =new ArrayList<GisPoint>();

	public List<GisPoint> getPoints() {
		return points;
	}

	public void setPoints(List<GisPoint> points) {
		this.points = points;
	}
	
	public boolean addPoint(GisPoint point) {
		this.points.add(point);
		return true;
	}
	
	public boolean addPoints(List<GisPoint> points) {
		this.points.addAll(points);
		return true;
	}
	
	public GisPolyg() {
		this.graphicType=GraphicType.POLYG;
	}

	@Override
	public void setGeometry() {
		if(this.points!=null && this.points.size()>0) {
			this.geometry="POLYGON(("+this.points.get(0).getX()
					+" "+this.points.get(0).getY();
			for(int k=1;k<this.points.size();k++) {
				this.geometry=this.geometry+","+this.points.get(0).getX()
						+" "+this.points.get(0).getY();
			}
			this.geometry=this.geometry+"))";
		}
		
	}
}
